// adminMockTest.ts
// 用于测试管理员模拟数据生成工具

import { generateDashboardOverviewData, generateRecentActivitiesData } from './adminMock'

// 测试生成控制台概览数据
console.log('===== 测试控制台概览数据 =====')
const overviewData = generateDashboardOverviewData()
console.log(JSON.stringify(overviewData, null, 2))
console.log('控制台概览数据包含八个关键指标：')
console.log(`1. 今日订单数量: ${overviewData.todayOrders}`)
console.log(`2. 总经销商用户数量: ${overviewData.totalDistributors}`)
console.log(`3. 总代理数量: ${overviewData.totalAgents}`)
console.log(`4. 产品总数: ${overviewData.totalProducts}`)
console.log(`5. 今日付款金额(USDT): ${overviewData.todayPaymentAmount}`)
console.log(`6. 总收入(USDT): ${overviewData.totalRevenue}`)
console.log(`7. 待处理提款申请金额(USDT): ${overviewData.pendingWithdrawAmount}`)
console.log(`8. 总提款金额(USDT): ${overviewData.totalWithdrawAmount}`)

// 测试生成最近活动数据
console.log('\n===== 测试最近活动数据 =====')
const recentActivities = generateRecentActivitiesData(5)
console.log('生成了5条最近活动记录:')
recentActivities.forEach((activity, index) => {
  console.log(`活动 ${index + 1}: ${activity.type} - ${activity.content} (${activity.time}) - 状态: ${activity.status}`)
})

// 检查数据结构是否完整
console.log('\n===== 数据结构检查 =====')

// 检查概览数据结构
console.log('控制台概览数据结构检查:')
let overviewDataCheck = true
const requiredOverviewFields = [
  'todayOrders', 'totalDistributors', 'totalAgents', 'totalProducts', 
  'todayPaymentAmount', 'totalRevenue', 'pendingWithdrawAmount', 'totalWithdrawAmount',
  'timestamp', 'growth'
]
for (const field of requiredOverviewFields) {
  if (!(field in overviewData)) {
    console.log(`错误: 缺少字段 ${field}`)
    overviewDataCheck = false
  }
}
if (overviewDataCheck) {
  console.log('控制台概览数据结构完整')
}

// 检查活动数据结构
console.log('最近活动数据结构检查:')
let activityDataCheck = true
if (recentActivities.length > 0) {
  const activity = recentActivities[0]
  const requiredActivityFields = [
    'id', 'type', 'time', 'timestamp', 'content', 'user', 'status', 'needsAction'
  ]
  for (const field of requiredActivityFields) {
    if (!(field in activity)) {
      console.log(`错误: 缺少字段 ${field}`)
      activityDataCheck = false
    }
  }
  
  // 检查user对象结构
  if ('user' in activity) {
    const userFields = ['id', 'name', 'role', 'avatar']
    for (const field of userFields) {
      if (!(field in activity.user)) {
        console.log(`错误: 用户对象缺少字段 ${field}`)
        activityDataCheck = false
      }
    }
  }
}
if (activityDataCheck) {
  console.log('最近活动数据结构完整')
}

console.log('\n测试完成') 
 